unit uEnemy;

interface

type
  TBaseEnemy = class(TObject)
  private
    FY: Byte;
    FX: Byte;
    FID: Byte;
    procedure SetX(const Value: Byte);
    procedure SetY(const Value: Byte);
    procedure SetID(const Value: Byte);
  public
    constructor Create;
    destructor Destroy; override;
    property ID: Byte read FID write SetID;
    property X: Byte read FX write SetX;
    property Y: Byte read FY write SetY;
  end;

  TEnemies = array of TBaseEnemy;
  
  TCreatures = class(TObject)
  private
    FEnemy: TEnemies;
    procedure SetEnemy(const Value: TEnemies);
  public
    procedure Add(const AX, AY, AID: Byte);
    property Enemy: TEnemies read FEnemy write SetEnemy;
    procedure Empty;
    constructor Create;
    destructor Destroy; override;
  end;
  
var
  Creatures: TCreatures;
  
implementation

uses uUtils;

{ TBaseEnemy }

constructor TBaseEnemy.Create;
begin
  ID := 0;
  X :=  0;
  Y :=  0;
end;

destructor TBaseEnemy.Destroy;
begin

  inherited;
end;

procedure TBaseEnemy.SetID(const Value: Byte);
begin
  FID := Value;
end;

procedure TBaseEnemy.SetX(const Value: Byte);
begin
  FX := Value;
end;

procedure TBaseEnemy.SetY(const Value: Byte);
begin
  FY := Value;
end;

{ TCreatures }

procedure TCreatures.Add(const AX, AY, AID: Byte);
var
  I: Word;
begin
  I := Length(FEnemy) + 1;
  SetLength(FEnemy, I);
  FEnemy[I - 1] := TBaseEnemy.Create;
  with FEnemy[I - 1] do
  begin
    X := AX;
    Y := AY;
    ID := AID;
  end;

end;

constructor TCreatures.Create;
//var
//  I: Word;
begin
//  for I := 0 to 49 do 
//    Add(Rand(10, 140), Rand(10, 140), 0);
end;

destructor TCreatures.Destroy;
var
  I: Word;
begin
  if (Length(Enemy) > 0) then
    for I := 0 to Length(Enemy) - 1 do 
      Enemy[I].Free;
  inherited;
end;

procedure TCreatures.Empty;
begin
  SetLength(FEnemy, 0);
end;

procedure TCreatures.SetEnemy(const Value: TEnemies);
begin
  FEnemy := Value;
end;

initialization
//  Creatures := TCreatures.Create;

finalization
  Creatures.Free;
  
end.
